package com.onion.utils.data;

import java.io.UnsupportedEncodingException;

/**
 * String数据转换器
 */
public class DataStringConverter implements GenericDataConverter<String> {

    @Override
    public Class<String> getType() {
        return String.class;
    }

    @Override
    public String convert(byte[] bytesData, String charset) {
        try {
            return new String(bytesData, charset);
        } catch (UnsupportedEncodingException e) {
            throw new RuntimeException("数据转换异常！", e);
        }
    }

    @Override
    public String convert(String strData) {
        return strData;
    }

}